package cn.ycc1;

/**
 * 汉诺塔
 * @author ycc
 * @date 2024/6/4
 */
public class Hanoi {
    public static void main(String[] args) {
//        hanoi(3, "A", "B", "C");
        hanoi(4, "A", "B", "C");
    }

    public static void hanoi(int n, String from, String temp, String to) {
        if (n == 1) {
            System.out.println(from + "->" + to);
        } else {
            hanoi(n - 1, from, to, temp);
            System.out.println(from + "->" + to);
            hanoi(n - 1, temp, from, to);
        }
    }
}
